(function (exports) {
    var $ = null;

    var RecordLayer = cc.Layer.extend({
        onEnter: function () {
            cc.Layer.prototype.onEnter.call(this);

            var data = {
                UserID: gameData.uid + "",
                GameID: app.area + "",
                Role: "user"
            };
            network.sendProto(1053, data);
        },
        addListener: function (code, listener) {
            network.addListener(code, listener, this);
        },
        onExit: function () {
            cc.Layer.prototype.onExit.call(this);
            network.removeListenersForTarget(this);
        },
        ctor: function () {
            this._super();
            var that = this;

            var scene = loadNodeCCS(res.RecordLayer_json, this);
            $ = create$(this.getChildByName('Layer'));
            this._$ = $;

            this.addListener(1054, function (data) {
                that._LogData = data.LogData;
                $('tip_no').setVisible(that._LogData.length <= 0);
                var tableViewSize = $('tableViewLayer').getSize();

                var tableviewLayer = $('tableViewLayer');
                var tableview = new cc.TableView(that, cc.size(tableViewSize.width, tableViewSize.height));
                tableview.setDirection(cc.SCROLLVIEW_DIRECTION_VERTICAL);
                tableview.setVerticalFillOrder(cc.TABLEVIEW_FILL_TOPDOWN);
                tableview.x = 0;
                tableview.y = 0;
                tableview.setDelegate(that);
                tableview.setBounceable(true);
                tableviewLayer.addChild(tableview);

                hideLoading();

            });

            TouchUtil.setOnclickListener($('btn_close'), function (node) {
                that.removeFromParent(true);
            });

        },
        tableCellTouched: function (table, cell) {
        },
        tableCellSizeForIndex: function (table, idx) {
            return cc.size(930, 52);
        },
        tableCellAtIndex: function (table, idx) {
            var cell = table.dequeueCell();
            if (cell == null) {
                cell = new cc.TableViewCell();
                var row0 = ccs.load(res.Record_item_json, getCCSFileNamePath(res.Record_item_json)).node;
                row0.setName('cellrow');
                cell.addChild(row0);
            }

            var node = cell.getChildByName('cellrow');
            $('lb_name', node).setString(this._LogData[idx].MoneyGear / 100 + "元");
            $('lb_time', node).setString(this._LogData[idx].LogTime);

            return cell;
        },
        numberOfCellsInTableView: function (table) {
            return this._LogData.length
        },
        scrollViewDidScroll: function (view) {
            var size = view.getContentOffset();

        },
        scrollViewDidZoom: function (view) {
        },
        _offsetFromIndex: function (view) {
        },

    });
    exports.RecordLayer = RecordLayer;

})(window);